route.ts 547 B

123456789101112
  1. import { NextRequest, NextResponse } from 'next/server';
  2. import { ResultDto } from '@/types/response/common';
  3. import { fetchJson } from '@/lib/utils/server';
  4. export async function GET(request: NextRequest, { params }: { params: Promise<{ path?: string[] }> }) {
  5. const { path } = await params;
  6. const subPath = path ? `/${path.join('/')}` : '';
  7. const endpoint = `/api/ranking${subPath}`;
  8. const url = new URL(request.url);
  9. const res: ResultDto = await fetchJson(`${endpoint}${url.search}`, { method: 'GET' });
  10. return NextResponse.json(res);
  11. }